package com.wb3.organizer.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.HibernateTemplate;

import com.wb3.organizer.dao.AppointmentDAO;
import com.wb3.organizer.model.Account;
import com.wb3.organizer.model.Appointment;

public class AppointmentDAOImpl implements AppointmentDAO {

	private HibernateTemplate ht;

	public HibernateTemplate getHt() {
		return ht;
	}

	public void setHt(HibernateTemplate ht) {
		this.ht = ht;
	}

	public void save(Appointment appointment) {
		ht.save(appointment);
	}

	public void update(Appointment appointment) {
		ht.update(appointment);
	}

	public void delete(Appointment appointment) {
		ht.delete(appointment);
	}

	@SuppressWarnings("unchecked")
	public List<Appointment> getAllByAccount(Account account) {
		List<Appointment> appointments = ht.find("from Appointment a where a.account = ?", account);
		return appointments;
	}

	public Appointment getAppointmentById(int app_id) {
		return ht.get(Appointment.class, app_id);
	}
}
